using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using MbUnit.Framework;

namespace UnitTests.Configurator
{
	[TestFixture]
	public class TestSelectNode
	{
		[Test]
		public void TestOne()
		{
			XmlDocument document = new XmlDocument();
			document.Load("SomeDocument.xml");
			XmlNode node = document.SelectSingleNode("/document/myObject");
			node.ToString();
		}

		[Test]
		public void TestTwo()
		{
			Create("System.Collections.Generic.List", typeof (int));
			Type listType = Type.GetType("System.Collections.Generic.List`1");
			Type listType2 = Type.GetType("System.Collections.Generic.List`1").MakeGenericType(typeof(string));
			ArrayList foo = new ArrayList();
			List<string> strList = new List<string>();
			string[] strings = (string[]) Array.CreateInstance(typeof (string), 4);
			List<string> foo3 = new List<string>();
			Type type = typeof (List<string>);

			Assert.IsTrue(foo3.GetType().GetGenericTypeDefinition() == listType);

			Type stringArrayType = strings.GetType();
			Assert.IsTrue(stringArrayType.IsArray);
			Assert.AreEqual(stringArrayType.GetElementType(), typeof(string));

			Type[] types = type.GetGenericArguments();

			Assert.IsTrue(strings.GetType().IsArray);
			Assert.IsTrue(strList.GetType().IsGenericType);
		}

		static object Create(string name, params Type[] types)
		{
			string t = name + "`" + types.Length;
			Type generic = Type.GetType(t).MakeGenericType(types);
			return Activator.CreateInstance(generic);
		}

		[SetUp]
		public void SetUp()
		{

		}

		[TearDown]
		public void TearDown()
		{

		}

	}
}